<template>
	<view>
		<uni-card v-for="item in dataList" :key="item.id" @click="showDetail(item.id)" :title="`订单号 ` + item.orderNo"
			:extra="showOrderStatus(item.orderStatus)">
			<view class="container">
				<view class="text-right margin-right">乘机人</view>
				<view>
					<template v-for="(psg, index) in item.passengers" :key="index">
						<text>{{ psg.name }}</text>
					</template>
				</view>
				<view class="text-right margin-right">日期</view>
				<view>
					<template v-for="(flt, index) in item.flights" :key="index">
						<text>{{ flt.ddate.substring(5) }}</text>
					</template>
				</view>
				<view class="text-right margin-right">航班号</view>
				<view>
					<template v-for="(flt, index) in item.flights" :key="index">
						<text>{{ flt.flightNo }}</text>
					</template>
				</view>
				<view class="text-right margin-right">出发</view>
				<view>
					<template v-for="(flt, index) in item.flights" :key="index">
						<text>{{ flt.dportName }}</text>
					</template>
				</view>
				<view class="text-right margin-right">到达</view>
				<view>
					<template v-for="(flt, index) in item.flights" :key="index">
						<text>{{ flt.aportName }}</text>
					</template>
				</view>
			</view>
			
			<template v-slot:actions>
				<view class="text-right">
					<button class="uni-button" size="mini" type="primary"
						@click.stop="showDetail(item.id)">详情</button>
				</view>
			</template>

		</uni-card>
	</view>
</template>

<script setup>
	import {
		showFlightOrderStatus,
		showPayType,
		showItineraryType,
	} from "@/common/api/common.js";
	import {
		showCustomerName,
		showPassengerName
	} from "@/common/api/common.js";

	// 定义 props 接收父组件传递的数组
	const props = defineProps({
		dataList: {
			type: Array,
			required: true,
		},
		loading: {
			type: Boolean,
			default: false
		}
	});

	function showDetail(id) {
		uni.navigateTo({
			url: '/pages/flight/FlightOrderDetail?id=' + id
		})
	}

	function showPsgName(info) {
		return showPassengerName(info, 0);
	}
	
	function showOrderStatus(status) {
		return showFlightOrderStatus(status)
	}
</script>

<style scoped>
	.uni-title__base {
		font-size: 15px;
		color: #333;
		font-weight: 500;
	}
</style>